package com.zrx.springboot.config;


import com.zrx.springboot.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //添加拦截器
        registry.addInterceptor(new LoginInterceptor())
                //拦截哪些 /**所有
                .addPathPatterns("/**")
                //静态资源也会被拦截包括css js
                //放行哪些
                .excludePathPatterns("/","/registration","/saveadmin","/checkadmin", "/login", "/css/**", "/fonts/**", "/images/**", "/js/**");
        //放行不拦
    }
}
